//
// Description: 1. 两数之和
// Created by Loading on 2022/3/27.
//

#include <bits/stdc++.h>

using namespace std;

vector<int> twoSum(vector<int> &nums, int target) {
    unordered_map<int, int> m;
    int n = nums.size();
    for (int i = 0; i < n; ++i) {
        if (m.find(target - nums[i]) != m.end()) {
            return {m[target - nums[i]], i};
        }
        m[nums[i]] = i;
    }
    return {};
}

int main() {
    vector<int> nums{2, 7, 11, 15};
    int target = 9;
    auto res = twoSum(nums, target);
    cout << res[0] << ' ' << res[1] << endl;

    return 0;
}